package com.fucking.great.context.engine;

import cn.hutool.core.util.StrUtil;

import java.util.Collection;
import java.util.Map;


public abstract class BaseEngine implements Engine{

    @Override
    public  Object engine(String scriptStr, Map<String, Object> variable) {
        return engine(StrUtil.EMPTY,scriptStr,variable);
    }
    @Override
    public  Object engine(String scriptStr, Map<String, Object> variable, String... importStr) {
        return engine(StrUtil.EMPTY,scriptStr,variable,importStr);
    }
    @Override
    public  Object engine(Collection<?> importStr, String scriptStr, Map<String, Object> variable) {
        return engine(StrUtil.EMPTY,importStr,scriptStr,variable);
    }

    @Override
    public  Object engine(String cacheKey, Collection<?> importStr, String scriptStr, Map<String, Object> variable) {
        String [] importStrs = new String[importStr.size()];
        importStr.toArray(importStrs);
        return engine(cacheKey,scriptStr,variable,importStrs);
    }

    public abstract   Object engine(String cacheKey, String scriptStr, Map<String, Object> variable, String... importStr);
    public abstract Object engine(String cacheKey, String scriptStr, Map<String, Object> variable);

    @Override
    public  Object runEngine(String cacheKey, Map<String, Object> variable){
        return engine(cacheKey,null,variable);
    }

}
